<template>
  <div>
    <r-search
      ref="search"
      :searchData="searchData"
      :searchForm="searchForm"
      :searchHandle="searchHandle"
      :inline="true"
    />

    <r-table
      :isIndex="false"
      :isPagination="true"
      :isHandle="true"
      :tableData="tableData"
      :tableCols="tableCols"
      :tablePage="pagination"
      :loading="tableLoading"
      :isSelection="false"
      @refresh="page()"
    >
    </r-table>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      orderDetail: {},
      mealCharge_detail: {},
      searchData: {
        deviceNo: "",
        stime: "",
        etime: ""
      },
      searchForm: [
        {
          type: "input",
          placeholder: "Device Number",
          prop: "deviceNo",
          width: 240
        },
        // {
        //   type: "daterange", placeholder: "时间", prop: "date", width: 300, change: (val) => {
        //     if (val) {
        //       this.searchData.stime = val[0];
        //       this.searchData.etime = val[1];
        //     } else {
        //       this.searchData.stime = '';
        //       this.searchData.etime = '';
        //     }
        //   }
        // },
        {
          type: "date",
          placeholder: "Start Date",
          prop: "stime",
          width: 230,
          change: val => {
            this.searchData.stime = val;
          }
        },
        {
          type: "date",
          placeholder: "End Date",
          prop: "etime",
          width: 230,
          change: val => {
            this.searchData.etime = val;
          }
        }
      ],
      searchHandle: [
        {
          type: "primary",
          label: "Search",
          plain: true,
          handle: e => {
            this.zeroFn();
            this.getData();
          }
        },
        {
          label: "Reset",
          buttonss: true,
          icon: "el-icon-refresh-right",
          handle: e => {
            this.searchData = {
              deviceNo: "",
              stime: "",
              etime: ""
            };
            this.zeroFn();
            this.getData();
          }
        }
      ],
      tableLoading: false,
      tableData: [],
      tableCols: [
        // { label: "ID", prop: "id", },
        { label: "Device Number", prop: "deviceNo" },
        { label: "Information Type", prop: "typeName" },
        { label: "Alarm Information", prop: "alarm", overflow: true },
        { label: "Submission Time", prop: "stime" }
      ],
      pagination: { limit: 10, page: 1, total: 0 }
    };
  },
  created() {
    // let params = this.$route.query
    // if (params.sn) {
    //   this.searchData.sn = params.sn
    //   // this.$message.info(`已进行搜素Current[${params.sn}]Device Number`)
    // }
    this.getData();
  },
  mounted() {},
  methods: {
    zeroFn() {
      this.pagination.limit = 10;
      this.pagination.page = 1;
      this.pagination.total = 0;
    },
    async getData() {
      let params = {
        id: this.searchData.id,
        deviceNo: this.searchData.deviceNo,
        stime: this.searchData.stime,
        etime: this.searchData.etime,
        pageNum: this.pagination.page,
        pageSize: this.pagination.limit
      };
      const res = await this.apis.alarmGetList2(params);
      if (res.code == 200) {
        this.tableData = res.rows || [];
        this.pagination.total = res.total;
      }
    },
    page() {
      this.getData();
    }
  }
};
</script>

<style scoped lang="scss"></style>
